package edu.cibertec.sicsolutions.vfs.service;

import java.util.Map;

import org.apache.log4j.Logger;

import edu.cibertec.sicsolutions.exception.DaoException;
import edu.cibertec.sicsolutions.exception.DomainException;
import edu.cibertec.sicsolutions.vfs.dao.votacion.SessionTrackingDao;
import edu.cibertec.sicsolutions.vfs.domain.votacion.SessionTracking;
import edu.cibertec.sicsolutions.vfs.spring.SpringContext;

public class SessionTrackingService {
	
	private static final Logger log = Logger.getLogger(SessionTrackingService.class);
	private static final SessionTrackingDao sessionTrackingDao = (SessionTrackingDao)SpringContext.get(SessionTrackingDao.class);	
	

	/**
	 * Get Object of Data Base By PK	 
	 * @param sessionTracking
	 * @return
	 * @throws DomainException
	 */
	public static SessionTracking getSessionTrackingByPk(SessionTracking sessionTracking) throws DomainException{
		try{
			return sessionTrackingDao.getSessionTrackingByPk(sessionTracking);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}		
	}
	
	/**
	 * Save Object
	 * @param sessionTracking
	 * @return
	 * @throws DomainException
	 */	
	public static void insertSessionTracking (SessionTracking sessionTracking) throws DomainException{
		try{
			sessionTrackingDao.insertSessionTracking(sessionTracking);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}		
	}
	
	/**
	 * Update Object 
	 * @param sessionTracking
	 * @return
	 * @throws DomainException
	 */
	public static void updateSessionTracking (SessionTracking sessionTracking) throws DomainException{		
		try{
			sessionTrackingDao.updateSessionTracking(sessionTracking);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}
	
	/**
	 * Update Object 
	 * @param sessionTracking
	 * @return
	 * @throws DomainException
	 */
	public static void updateSessionTrackingByMap (Map map) throws DomainException{		
		try{
			sessionTrackingDao.updateSessionTrackingByMap(map);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}
	
	/**
	 * Delete Object	 
	 * @param sessionTracking
	 * @return
	 * @throws DomainException
	 */
	public static void deleteSessionTrackingByPk(SessionTracking sessionTracking) throws DomainException{		
		try{
			sessionTrackingDao.deleteSessionTrackingByPk(sessionTracking);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}
	
	/**
	 * Find Object By Filters
	 * @param sessionTracking
	 * @return
	 * @throws DomainException
	 */
	public static SessionTracking[] findSessionTrackingByClass(SessionTracking sessionTracking) throws DomainException{		
		try{
			return sessionTrackingDao.findSessionTrackingByClass(sessionTracking);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}

	public static SessionTracking[] resultElectoresOnLineByConsulado(Map map) throws DomainException{		
		try{
			return sessionTrackingDao.resultElectoresOnLineByConsulado(map);
		} catch (DaoException e) {
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		} catch (Exception e){
			log.error(e.getMessage(), e);
			throw new DomainException(e.getMessage(), e);
		}
	}

}
